package niuke.week4;

import java.util.Scanner;

/**
 给定一个字符串str，只能在str的后面添加字符，生成一个更长的字符串，更长的字符串需要
 包含两个str，且两个str开始的位置不能一样。求最少添加多少个字符。

 */
public class MinAddNumberOfChar {

    public static int[] getPrefix(String []str){
        int n = str.length;
        int[]dp = new int[n];

        for (int i = 1; i < n; i++) {
            if(str[i].equals(str[dp[i - 1]]))
                dp[i] = dp[i-1]+1;// A B A A B A
            else if(!str[i].equals(str[0]))  //A B A B C
                dp[i] = 0;
            else dp[i] = 1;//A B A B A

        }
        return dp;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String next = sc.next();
        char[] chars = next.toCharArray();
        String[] strings = new String[chars.length];
        for (int i = 0; i < chars.length; i++) {
            strings[i] = String.valueOf(chars[i]);
        }

        int[] prefix = getPrefix(strings);
        System.out.println(strings.length-prefix[strings.length-1]);
    }
}